//不同时期的订单数量
var orderNumSectionChart = echarts.init(document.getElementById('orderNumSection'));
orderNumSectionChart.setOption({
    title: {
        left: 'left',
        top: '8%',
        text: '不同时段订单数变化',
        textStyle: {
            color: '#fff',
            textShadowBlur: 3,
            textShadowOffsetY: 3,
        }
    },
    tooltip: {
        trigger: 'axis'
    },
    legend: {
        top: "12%",
        left: 'right',
        icon: 'circle',
        textStyle: {
            color: '#fff',
            fontFamily: '微软雅黑'
        },
        data: ['工作日', '周末', '假期']
    },
    grid: {
        left: '17%',
        top: '28%',
        height: '55%'
    },
    /*toolbox: {
        top: "12%",
        show: true,
        feature: {
            dataZoom: {
                yAxisIndex: 'none'
            },
            dataView: {readOnly: false},
            magicType: {type: ['line', 'bar']},
            restore: {},
            saveAsImage: {}
        }
    },*/
    xAxis: {
        data: [],
        type: 'category',
        boundaryGap: false,
        axisLabel: {
            textStyle: {
                color: '#fff'
            }
        },
        axisTick: {
            lineStyle: {
                color: '#0099FF'
            }
        }
    },
    yAxis: {
        type: 'value',
        axisLabel: {
            formatter: '{value} '
        },
        axisLabel: {
            textStyle: {
                color: '#fff'
            }
        },
    },
    series: [
        {
            name: '工作日',
            type: 'line',
            smooth: true,
            data: [],
            markLine: {
                data: [
                    {type: 'average', name: '平均值'}
                ]
            },
            itemStyle: {
                normal: {
                    color: '#fba025',
                }
            }
        },
        {
            name: '周末',
            type: 'line',
            smooth: true,
            data: [],
            markLine: {
                data: [
                    {type: 'average', name: '平均值'}
                ]
            },
            itemStyle: {
                normal: {
                    color: '#02defd',
                }
            }
        },
        {
            name: '假期',
            type: 'line',
            smooth: true,
            data: [],
            markLine: {
                data: [
                    {type: 'average', name: '平均值'}
                ]
            },
            itemStyle: {
                normal: {
                    color: '#e71e18',
                }
            }
        }
    ]
});
orderNumSectionChart.showLoading();
var timeInSection = [];
var countInWorkday = [];
var countInWeekend = [];
var countInHoliday = [];
$.ajax({
    type: "POST",
    async: true,
    url: "OrderNumSectionServlet",
    data: {},
    dataType: "json",
    success: function (resultOfOrderNumSection) {
        if (resultOfOrderNumSection) {
            for (var i = 0; i < 24; i++) {
                timeInSection.push(resultOfOrderNumSection[i].timeSection);
                countInWorkday.push(resultOfOrderNumSection[i].count);
                countInWeekend.push(resultOfOrderNumSection[i + 24].count);
                countInHoliday.push(resultOfOrderNumSection[i + 48].count);
            }
            orderNumSectionChart.hideLoading();
            orderNumSectionChart.setOption({
                xAxis: {
                    data: timeInSection
                },
                series: [{
                    data: countInWorkday
                }, {
                    data: countInWeekend
                }, {
                    data: countInHoliday
                }]
            })
        }
    },
    error: function (errorMsg) {
        alert("ERROR!!!!");
        orderNumSectionChart.hideLoading();
    }
})